import {
    resetRouter
} from "@/router";
import qs from "qs"
const getDefaultState = () => {
    return {
        video_url: "",
        cover_url: "",
        commentList: []
    };
};
import {
    getVideoCommentList
} from "@/api/modules/video"
const state = getDefaultState();

const mutations = {
    // 存储发布视频url
    SETVIDEOURL(state, video_url) {
        state.video_url = video_url;
    },
    // 存储发布视频封面url
    SETCOVERURL(state, cover_url) {
        console.log('store', cover_url);
        state.cover_url = cover_url;
    },
    // 获取当前评论列表
    GETCURRENTCOMMENTLIST(state, commentList) {
        state.commentList = commentList;
    }
};

const actions = {
    // 获取当前评论列表
    async getCurrentCommentList({
        commit
    }, {
        video,
        limit,
        page
    }) {
        const res = await getVideoCommentList(video.info.id, limit, page)
            // console.log("commentlist",res)
        if (res.status == 200 || res.status == 422) {
            commit("GETCURRENTCOMMENTLIST", res.data.payload)
            return "success"
        } else {
            return "error"
        }
    }
};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
};